$LOAD_PATH.unshift File.join(File.dirname(__FILE__),'..','ext_pr1/lib')
require 'ext_pr1_v4'

#Summe von Quadraten
#Funktion zur Ermittlung der beiden größten Quadrate und Wiedergabe der Summen
#Nat x Nat x Nat => Nat x Nat => Nat
#larger_sum_square(val1, val2, val3) => ((max1 **2) + (max2 **2))
#test (3,2,1) => 13, (0,0,0) => 0, (2,1,3) =>  13, (1,2,3) => 13, (1,2,2) => 8,
#(2,1,2) => 8, (2,2,1) => 8, (2,2,2) => 8
#("10",2,1) => Err, (2,"10",1) => Err, (1,2,"10") => Err, (1.1,2,1) => Err,
#(2,1.1,1) => Err, (2,1,1.1) => Err,  (-10,2,1) => Err, ... (2,-10,1) => Err,
#(2,1,-10) => Err

def larger_sum_square(val1, val2, val3)
check_pre((
val1.nat? and
val2.nat? and
val3.nat? and
val1 >=0 and
val2 >=0 and
val3 >=0 ))

(max(val1, val2, val3)[0] **2 ) + (max(val1, val2, val3)[1] **2)
end

def max(val1, val2, val3)

if  (val1 <= val2 and val1 <= val3)
then  [val2, val3]
elsif (val2 <= val1 and val2 <= val3)
then [val1, val3]
else [val1, val2]
end
end



